const user = require("../sql/user");
const sql = require("../sql/index");
// 后期优化
exports.reheaderimgs = function () {
    return (req, res, next) => {
        // console.log(req.query.userID)
        // 判断当前登录用户的userid
        sql.get(user, { userid: req.query.userID }, data => {
            if (req.query.username == "") {
                res.send(JSON.stringify({
                    code: 5,
                    msg: "昵称修改失败,不能为空"
                }));
            } else {
                sql.set(user, { username: data[0].username }, { username: req.query.username }, () => {
                    res.send(JSON.stringify({
                        code: 6,
                        msg: "昵称修改成功",
                        age: data[0].username,
                    }));
                })
            }
        })
    }
}